From c6ac74db2bc73aa1438ef3955c851004a6bace4b Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 25 Jan 2004 02:33:34 +0000 Subject: [PATCH] Watchlist caching, and some junk in DefaultSettings.php which will hopefully be used eventually --- includes/DefaultSettings.php | 8 ++++++++ includes/SpecialWatchlist.php | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 0893d83bd3..e24997fb63 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -39,6 +39,11 @@ $wgDBminWordLen = 4; $wgDBtransactions = false; # Set to true if using InnoDB tables $wgDBmysql4 = false; # Set to true to use enhanced fulltext search +# Database load balancer +$wgDBservers = false; # e.g. array("larousse", "pliny") +$wgDBloads = false; # e.g. array(0.6, 0.4); + + # memcached settings # See docs/memcached.doc # @@ -141,6 +146,9 @@ $wgDisableCookieCheck = false; $wgAllowExternalImages = true; $wgMiserMode = false; # Disable database-intensive features +$wgDisableQueryPages = false; # Disable all query pages if miser mode is on, not just some +$wgUseWatchlistCache = false; # Generate a watchlist once every hour or so +$wgWLCacheTimeout = 3600; # The hour or so mentioned above # To use inline TeX, you need to compile 'texvc' (in the 'math' subdirectory # of the MediaWiki package and have latex, dvips, gs (ghostscript), and diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index 136cb3f69b..08d8ae4cc6 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -4,7 +4,8 @@ include_once( "WatchedItem.php" ); function wfSpecialWatchlist() { - global $wgUser, $wgOut, $wgLang, $wgTitle; + global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc; + global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname; global $days, $limit, $target; # From query string $fname = "wfSpecialWatchlist"; @@ -38,6 +39,17 @@ function wfSpecialWatchlist() $wgOut->addHTML( "done.\n

" ); } + if ( $wgUseWatchlistCache ) { + $memckey = "$wgDBname:watchlist:id:" . $wgUser->getId(); + $cache_s = @$wgMemc->get( $memckey ); + if( $cache_s ){ + $wgOut->addHTML( wfMsg("wlsaved") ); + $wgOut->addHTML( $cache_s ); + return; + } + } + + $sql = "SELECT COUNT(*) AS n FROM watchlist WHERE wl_user=$uid"; $res = wfQuery( $sql, DB_READ ); $s = wfFetchObject( $res ); @@ -162,6 +174,10 @@ function wfSpecialWatchlist() wfFreeResult( $res ); $wgOut->addHTML( $s ); + + if ( $wgUseWatchlistCache ) { + $wgMemc->set( $memckey, $s, $wgWLCacheTimeout); + } } -- 2.20.1